

DECLARE @idx int


set @idx = (select top 1  idx from @MyTable order by idx )


while isnull(@idx,-1) <> -1
begin
	print @idx

	set @idx = (select top 1 idx from @MyTable where idx > @idx )
end



